-- fruits_drop
-- created by xinj
-- 掉落金币(基准值 + 浮动值)

return {
    apply = function(prop, baseValue)
        return baseValue + prop[3];
    end,

    -- 攻击触发
    trigger = function(who, prop, arg)
        if who.type ~= OBJECT_TYPE_MONSTER then
            return;
        end

        local min = tonumber(prop[2]);
        local max = prop[3];
        assert(max >= min);

        local differ = max - min;
        local rand = DungeonM.getRandSeed("fruits_drop");
        -- 数量
        local amount = min + rand % (differ + 1);

        local bonus = {1, 1110, amount,};

        -- 设置奖励
        local class = DungeonM.getClassByType(GRID_TYPE_ITEM);
        local pos = who:getPos();
        -- 找个空位
        pos = SummonM.findSummonPos(pos);

        if pos <= 0 then
            -- 没有空格了就不管了
            return;
        end
        DungeonM.transformGrid(class, pos, GRID_STATE_OPEN, {["bonus"] = bonus, });

        return true;
    end,

    record = function(target, prop, path)
        return false;
    end
};
